#include "configdialog.h"

ConfigDialog::ConfigDialog ( QWidget *parent ) : QDialog ( parent ), Ui::ConfigDialog()
{
	setupUi ( this );

//	connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
//	connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
	connect ( keepRatioCheck, SIGNAL ( stateChanged ( int ) ), this, SLOT ( checkRatio ( int ) ) );

	keepRatioCheck -> setCheckState ( Qt::Checked );
}

ConfigDialog::~ConfigDialog()
{}

int ConfigDialog::getWidth()
{
	return widthSpin -> value();
}

int ConfigDialog::getHeight()
{
	return heightSpin -> value();
}

void ConfigDialog::checkRatio ( int state )
{
	switch ( state )
	{
		case Qt::Checked:
			connect ( heightSlider, SIGNAL ( valueChanged ( int ) ), widthSlider, SLOT ( setValue ( int ) ) );
			connect ( heightSpin, SIGNAL ( valueChanged ( int ) ), widthSpin, SLOT ( setValue ( int ) ) );
			connect ( widthSlider, SIGNAL ( valueChanged ( int ) ), heightSlider, SLOT ( setValue ( int ) ) );
			connect ( widthSpin, SIGNAL ( valueChanged ( int ) ), heightSpin, SLOT ( setValue ( int ) ) );
			break;
		case Qt::Unchecked:
			disconnect ( heightSlider, SIGNAL ( valueChanged ( int ) ), widthSlider, SLOT ( setValue ( int ) ) );
			disconnect ( heightSpin, SIGNAL ( valueChanged ( int ) ), widthSpin, SLOT ( setValue ( int ) ) );
			disconnect ( widthSlider, SIGNAL ( valueChanged ( int ) ), heightSlider, SLOT ( setValue ( int ) ) );
			disconnect ( widthSpin, SIGNAL ( valueChanged ( int ) ), heightSpin, SLOT ( setValue ( int ) ) );
			break;
		default:
			break;
	}
}
